1. Field of the Invention
The present invention relates to a technique of extracting an edge feature amount from an image.
2. Description of the Related Art
There have been proposed techniques of extracting an edge feature from an image to detect an object in the image or the tilt of an electronic component, or determine defective and non-defective items. Japanese Patent Publication No. 07-072909 and Japanese Patent Laid-Open No. 2002-175528 propose techniques using, as an edge feature, an edge direction histogram obtained by accumulating edge intensities in each direction for each pixel of an image.
The edge direction histogram represents the cumulative feature in each edge direction within a predetermined region of an image, and can therefore accurately reflect the feature of an object without being affected by noise, unlike a method of directly detecting edge positions. The edge direction histogram calculation method will be described below.
FIG. 1 is a view for explaining a local region of an image and a pixel in the local region. Referring to FIG. 1, reference numeral 101 denotes an entire image; 102, a local region of the image 101; and 103, a pixel of interest in the local region 102. In FIG. 1, the edge intensity of the pixel 103 of interest in the horizontal direction is represented by Ih, and the edge intensity in the vertical direction as Iv. FIG. 2 is a view showing the pixel 103 of interest and eight pixels around it.
Under these circumstances, an edge intensity Fn in each direction is calculated concerning the pixel 103 of interest. There are eight edge directions d1 to d8, as shown in FIG. 2. In this case, the edge intensity Fn in each direction is calculated byFn=Ih×sin θn+Iv×cos θn  (1)
n12345678θn0°22.5°45°67.5°90°112.5°135°157.5°
Next, the pixels in the local region 102 are scanned, as indicated by 302 in FIG. 3. Calculation processing based on equation (1) is performed for each pixel in the local region 102 defined as the pixel 103 of interest, thereby calculating edge intensities in the eight directions for each pixel.
Finally, the edge intensities of all pixels in the local region 102 are added for each direction to calculate the edge direction histogram in the local region 102. At this time, a method (conventional method A) disclosed in Japanese Patent No. 02766118 or a method (conventional method B) disclosed in Japanese Patent No. 02985893 is used. The conventional method A adds only an edge intensity in a direction in which the edge intensity is maximum to the edge direction histogram. The conventional method B adds the edge intensities in all eight directions to the edge direction histogram. FIG. 3 shows an example 301 of an edge direction histogram calculated in this way. The thus calculated histogram will be referred to as a “local region edge histogram” hereinafter.
In the above-described method, the number of edge directions of the pixel of interest is eight, and edge intensities in the eight directions are always calculated for each pixel. However, there also exists a method of calculating only an edge intensity in one direction. In this case, an edge intensity d and an edge direction θ are calculated byd=√{square root over ((Ih)2+(Iv)2)}{square root over ((Ih)2+(Iv)2)}  (2)θ=arctan(Iv/Ih)  (3)
A case wherein a detection target has a nonlinear contour, for example, the edge feature of a shoulder portion in person detection will be described below. In an image 400 of a person shown in FIG. 4, reference numeral 401 indicates a region around a shoulder of the person. The region 401 is enlarged in FIG. 4. Reference numeral 403 represents the distribution of edge intensities F1 to F8 in the eight directions calculated using equation (1) for a pixel 402 of interest in the region 401. Note that the distribution 403 is obtained for one pixel, and called a “pixel edge histogram”.
As is apparent from the distribution 403, the edge intensity of the pixel 402 of interest is maximum in the direction d7. However, the edge intensities are high in the near directions d6, d8, and d1 as well. In fact, the edge of a human shoulder portion exhibits not a linear contour, i.e., an edge intensity extremely high in one direction but a round contour. For this reason, it is assumed possible to correctly reflect the feature of the contour shape of a detection target by obtaining feature amounts in a plurality of directions in which the edge intensities are high rather than by obtaining an edge intensity only in one direction as an edge feature.
In the conventional method A, only the maximum edge intensity in a direction, i.e., the direction d7 in this case is acquired as a feature amount, and added to the local region edge histogram. The pieces of edge intensity information in the directions other than d7 are discarded. As described above, if the detection target has a linear shape, the edge feature can sufficiently be reflected by the conventional method A. However, if the detection target is a nonlinear object such as a person or a car, the edge feature cannot sufficiently be reflected.
On the other hand, the conventional method B adds the edge intensities in all the eight directions to the local region edge histogram. In this case, edge intensities are added even for directions with low edge intensities such as the directions d2, d3, and d4. If the edge intensities in such directions with low edge intensities are added, the distribution of the local region edge histogram exhibits intensities to some degree even for these directions. For this reason, the degree of enhancement in the edge directions (d1, d6, d7, and d8 in the example of FIG. 4), which originally reflect the feature, may decrease.
FIG. 5 is a view showing a local region edge histogram 501 calculated by the conventional method A, and a local region edge histogram 502 calculated by the conventional method B. In the local region edge histogram 501, the edge intensity in the direction d7 is extremely enhanced relative to those in the remaining directions. However, in the local region edge histogram 502, the degree of enhancement of the intensity in the direction d7 is lower than those in the remaining directions.